import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:github_client_app/router/routes.dart';

class NavigatorUtil {
  static void push(BuildContext context, String path,
      {bool replace = false, bool clearStack = false, Object? arguments}) {
    Routes.router.navigateTo(
      context,
      path,
      replace: replace,
      clearStack: clearStack,
      transition: TransitionType.inFromRight,
      // routeSettings需要在对应页面接收：ModalRoute.of(context)?.settings.arguments;
      routeSettings: RouteSettings(
        arguments: arguments,
      ),
    );
  }

  // replase
  static void replase(BuildContext context, String path,
      {bool replace = true, bool clearStack = false, Object? arguments}) {
    Routes.router.navigateTo(
      context,
      path,
      replace: replace,
      clearStack: clearStack,
      transition: TransitionType.inFromRight,
      // routeSettings需要在对应页面接收：ModalRoute.of(context)?.settings.arguments;
      routeSettings: RouteSettings(
        arguments: arguments,
      ),
    );
  }

  /// 返回
  static void back(BuildContext context) {
    Navigator.pop(context);
  }

  // 路由返回指定页面
  static void backUrl(BuildContext context, String path) {
    Navigator.popAndPushNamed(context, path);
  }

  // 路由返回指定页面
  static void backParams(BuildContext context, Object result) {
    Navigator.pop(context, result);
  }
}
